/**
 * Copyright &copy; 2015-2020 <a href="http://www.easyhis.com/">easyhis</a> All rights reserved.
 */
package com.easy.dfcapi.entity;

import javax.validation.constraints.NotNull;

import com.easy.common.utils.IdGen;
import com.fasterxml.jackson.annotation.JsonBackReference;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.easy.modules.sys.entity.User;

import com.easy.core.persistence.DataEntity;
import com.easy.common.utils.excel.annotation.ExcelField;

/**
 * 商品类别Entity
 * @author waylen chi
 * @version 2018-01-17
 */
public class ApiCategory extends DataEntity<ApiCategory> {
	
	private static final long serialVersionUID = 1L;
	private String id;		// id
	private Integer cateId;		// cate_id
	private String cateName;		// 分类名称
	private Integer cateImg;		// 类别图片id
	private String cateImgUrl;		// 类别图片id
	private ApiCategory parent;		// 当前类别父类
	private Integer sonSum;		// 含子类数，默认0
	private Integer isShow;		// 是否显示1-显示 0-不显示 2-平台下架
	private Integer sortNo;		// 排序，默认0
	private Date createTime;		// 创建时间
	private User createBy;		// 创建者
	private Date updateTime;		// 更新时间
	private User updateBy;		// 更新者
	private Integer delFlag;		// 删除标志
	
	public ApiCategory() {
		super();
	}

	public ApiCategory(String id){
		this.id = id;
	}

	public ApiCategory(Integer cateId){
		this.cateId = cateId;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@NotNull(message="cate_id不能为空")
	@ExcelField(title="cate_id", align=2, sort=0)
	public Integer getCateId() {
		return cateId;
	}

	public void setCateId(Integer cateId) {
		this.cateId = cateId;
	}
	
	@ExcelField(title="分类名称", align=2, sort=1)
	public String getCateName() {
		return cateName;
	}

	public void setCateName(String cateName) {
		this.cateName = cateName;
	}
	
	@ExcelField(title="类别图片id", align=2, sort=2)
	public Integer getCateImg() {
		return cateImg;
	}

	public void setCateImg(Integer cateImg) {
		this.cateImg = cateImg;
	}

	public String getCateImgUrl() {
		return cateImgUrl;
	}

	public void setCateImgUrl(String cateImgUrl) {
		this.cateImgUrl = cateImgUrl;
	}

	@JsonBackReference
	@ExcelField(title="当前类别父类", fieldType=ApiCategory.class, value="parent.name", align=2, sort=3)
	public ApiCategory getParent() {
		return parent;
	}

	public void setParent(ApiCategory parent) {
		this.parent = parent;
	}
	
	@ExcelField(title="含子类数，默认0", align=2, sort=4)
	public Integer getSonSum() {
		return sonSum;
	}

	public void setSonSum(Integer sonSum) {
		this.sonSum = sonSum;
	}
	
	@ExcelField(title="是否显示1-显示 0-不显示 2-平台下架", align=2, sort=5)
	public Integer getIsShow() {
		return isShow;
	}

	public void setIsShow(Integer isShow) {
		this.isShow = isShow;
	}
	
	@ExcelField(title="排序，默认0", align=2, sort=6)
	public Integer getSortNo() {
		return sortNo;
	}

	public void setSortNo(Integer sortNo) {
		this.sortNo = sortNo;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title="创建时间", align=2, sort=7)
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	@ExcelField(title="创建者", align=2, sort=8)
	public User getCreateBy() {
		return createBy;
	}

	public void setCreateBy(User createBy) {
		this.createBy = createBy;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title="更新时间", align=2, sort=9)
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	@ExcelField(title="更新者", align=2, sort=10)
	public User getUpdateBy() {
		return updateBy;
	}

	public void setUpdateBy(User updateBy) {
		this.updateBy = updateBy;
	}
	
	@ExcelField(title="删除标志", dictType="del_flag", align=2, sort=11)
	public Integer getDelFlag() {
		return delFlag;
	}

	public void setDelFlag(Integer delFlag) {
		this.delFlag = delFlag;
	}

	/**
	 * 插入之前执行方法，需要手动调用
	 */
	public void preInsert(){
		this.id = IdGen.uuid();

		this.updateTime = new Date();
		this.createTime = this.updateTime;
	}

	/**
	 * 更新之前执行方法，需要手动调用
	 */
	public void preUpdate(){
		this.updateTime = new Date();
	}
	/**
	 * 插入之前执行方法，需要手动调用
	 */
	public void preInsert(Date now){
		this.id = IdGen.uuid();

		this.updateTime = now;
		this.createTime = this.updateTime;
	}

	/**
	 * 更新之前执行方法，需要手动调用
	 */
	public void preUpdate(Date now){
		this.updateTime = now;
	}


}